package com.jiac.coderunner.controller;

import com.jiac.coderunner.entity.FieldInfo;
import com.jiac.coderunner.util.DBInfo;
import com.jiac.coderunner.util.OutputJson;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/field")
public class FieldController {

    @RequestMapping("/list/{tableName}")
    public OutputJson getFields(@PathVariable String tableName){
        OutputJson opjson = new OutputJson();
        List<FieldInfo> columns = DBInfo.getTableCloumns(tableName);
        opjson.setObj(columns);
        return opjson;
    }
}
